//
//  SystemMsgInfoViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/26.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "SystemMsgInfoViewController.h"

@interface SystemMsgInfoViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, weak)UIImageView * backImageView;

@property (nonatomic, strong)UILabel * titleLabel;

@property (nonatomic, strong)UILabel * detailLabel;



@end

@implementation SystemMsgInfoViewController


- (void)viewWillAppear:(BOOL)animated{
    
    [self loadData];
}


- (void)loadData{
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    NSDictionary * parameterDict = @{@"id":self.idString};
    
    [[NetworkTool sharedTools] POST:@"system/detail" parameters:parameterDict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        NSDictionary * paramDict = responseObject[@"param"];
        
        self.titleLabel.text = [NSString stringWithFormat:@"%@",paramDict[@"title"]];
        self.detailLabel.text = [NSString stringWithFormat:@"%@",paramDict[@"content"]];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupNavBar];
    [self setupUI];
}


- (void)setupNavBar{
    
    self.title = @"系统消息";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToAccountView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}



- (void)setupUI{
    
    UIImageView * backImage = [[UIImageView alloc] init];
    
    backImage.image = [UIImage imageNamed:@"背景"];
    
    self.backImageView = backImage;
    
    [self.view addSubview:self.backImageView];
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
    
    self.titleLabel = [UILabel new];
    
    self.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    self.titleLabel.textColor = ColorWithRGB(0xd8d8d8);
    self.titleLabel.text = @"系统消息";
    
    [self.view addSubview:self.titleLabel];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
        make.top.mas_equalTo(self.view).offset(84 * SCREENH6);
    }];
    
    
    self.detailLabel = [UILabel new];
    
    self.detailLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13 * SCREENH6];
    self.detailLabel.textColor = ColorWithRGB(0xd8d8d8);
    self.detailLabel.numberOfLines = 0;
    self.detailLabel.text = @"爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭爱上都不擦洛杉矶打不出来节哀顺变多次签收单把擦拭";
    
    [self.view addSubview:self.detailLabel];
    
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.titleLabel);
        make.trailing.mas_equalTo(self.view).offset(-15 * SCREENH6);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * SCREENH6);
    }];
}



- (void)backToAccountView{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
